package com.clementheliou.cheliou.util.codec.binary;

import org.apache.commons.codec.binary.Base64;

/**
 * Utilities about the <i>Base64</i> algorithm, especially the implementation
 * provided by the Apache Commons.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link Base64}.
 * @since 1.0
 */
public abstract class Base64Utils {

	/**
	 * Decodes the given value using the <i>Base64</i> algorithm but does not
	 * chunk the output.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param valueToDecode the value to be encoded.
	 * @return the encoded value.
	 * @since 1.0
	 */
	public static String decodeBase64(final String valueToDecode) {
		return new String(Base64.decodeBase64(valueToDecode));
	}

	/**
	 * Encodes the given value using the <i>Base64</i> algorithm but does not
	 * chunk the output.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param valueToEncode the value to be encoded.
	 * @return the encoded value.
	 * @since 1.0
	 */
	public static String encodeBase64(final String valueToEncode) {
		return new String(Base64.encodeBase64(valueToEncode.getBytes()));
	}
}
